/*
 * @lc app=leetcode.cn id=440 lang=golang
 *
 * [440] 字典序的第K小数字
 */

// @lc code=start
func findKthNumber(n int, k int) int {
	cur:=1
	for {
		count:=(cur,n)
		if k>count{
			k-=count
			cur++
		}else{
			if k>1{
				cur*=10
				k--
			}else{
				break
			}
		}
	}
	return cur
}

func getCount(i ,n int)int{
	next:=i+1
	count:=0
	for i<=n{
		count+=min(next-1,n)-i+1
		i*=10
		next*=10
	}

	return count
}
// @lc code=end

